#ifndef MICROGRIDSYSTEM_H
#define MICROGRIDSYSTEM_H

#include <QObject>
#include <QVector>
#include <memory>
#include <QMap> // 添加缺失的头文件
#include "component.h"

class MicrogridSystem : public QObject {
    Q_OBJECT
public:
    explicit MicrogridSystem(QObject *parent = nullptr);

    // 组件管理
    void addComponent(Component* component);
    QVector<Component*> getComponents() const;
    Component* getComponentByName(const QString& name) const;

    // 仿真控制
    void runSimulation();
    void resetSimulation();

    // 数据获取
    QVector<double> getPowerHistory(const QString& componentName) const;

signals:
    void simulationFinished();
    void componentAdded(Component* component);

private:
    QVector<std::shared_ptr<Component>> m_components;
    QMap<QString, QVector<double>> m_powerHistory;
    int m_currentTimeStep = 0;
};

#endif // MICROGRIDSYSTEM_H
